{template '_header'}
<script type="text/javascript" src="../addons/ewei_shopv2/static/js/dist/area/cascade.js"></script>
<div class="page-heading"> 
    <span class='pull-right'>
        {ifp 'shop.refundaddress.add'}
        	<a class="btn btn-primary btn-sm" href="{php echo merchUrl('shop/refundaddress/add')}">添加新退货地址</a>
        {/if}
        <a class="btn btn-default  btn-sm" href="{php echo merchUrl('shop/refundaddress')}">返回列表</a>
    </span>
    <h2>{if !empty($item['id'])}编辑{else}添加{/if}退货地址 <small>{if !empty($item['id'])}修改【{$item['title']}】{/if}</small></h2>
</div>


<form {ife 'shop.refundaddress' $item}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data">
    <input type="hidden" name="id" value="{$item['id']}" />
    <div class="form-group">
        <label class="col-sm-2 control-label must">退货地址名称</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
            	<input type="text" id='title' name="title" class="form-control" value="{$item['title']}" data-rule-required='true' />
            {else}
            	<div class='form-control-static'>{$item['title']}</div>
            {/if}

        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label must">联系人</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
            	<input type="text" id='name' name="name" class="form-control" value="{$item['name']}"  required style="width: 300px;"/>
            {else}
            	<div class='form-control-static'>{$item['name']}</div>
            {/if}

        </div>`
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label must">手机</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
            	<input type="text" id='mobile' name="mobile" class="form-control" value="{$item['mobile']}" style="width: 300px;"/>
            {else}
            	<div class='form-control-static'>{$item['mobile']}</div>
            {/if}

        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">电话</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
            	<input type="text" id='tel' name="tel" class="form-control" value="{$item['tel']}" style="width: 300px;"/>
            {else}
            	<div class='form-control-static'>{$item['mobile']}</div>
            {/if}

        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">邮编</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
            	<input type="text" id='zipcode' name="zipcode" class="form-control" value="{$item['zipcode']}" style="width: 300px;"/>
            {else}
            	<div class='form-control-static'>{$item['zipcode']}</div>
            {/if}

        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label must">地址</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
	            <p>
	                <select id="sel-provance" name="province" onChange="selectCity();" class="select form-control" style="width:130px;display:inline;">
	                    <option value="" selected="true">省/直辖市</option>
	                </select>
	                <select id="sel-city" name="city" onChange="selectcounty(0)" class="select form-control" style="width:135px;display:inline;">
	                    <option value="" selected="true">请选择</option>
	                </select>
	                <select id="sel-area" name="area" class="select form-control" style="width:130px;display:inline;">
	                    <option value="" selected="true">请选择</option>
	                </select>
	            </p>
	            <p>
	                <input type="text" name="address" id="address" class="form-control" style="width:300px;" required value="{php echo $item['address']}">
	            </p>
            {/if}

        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label ">是否默认</label>

        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
	            <label class='radio-inline'>
	                <input type='radio' name='isdefault' id="isdefault1" value='1' {if $item['isdefault']==1}checked{/if} /> 是
	            </label>
	            <label class='radio-inline'>
	                <input type='radio' name='isdefault' id="isdefault0" value='0' {if $item['isdefault']==0}checked{/if} /> 否
	            </label>
            {else}
            	<div class='form-control-static'>{if empty($item['calculatetype'])}按重量计费{else}按件计费{/if}</div>
            {/if}
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label "></label>
        <div class="col-sm-9 col-xs-12">
            {ife 'shop.refundaddress' $item}
            	<input type="submit" value="提交" class="btn btn-primary"  />
            {/if}
            <input type="button" name="back" onclick='history.back()' {ifp 'shop.refundaddress.add|shop.refundaddress.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
        </div>
    </div>


</div>
</div>

</form>
</div>

<script language='javascript'>

    {ife 'shop.refundaddress' $item}
    $(function(){
        cascdeInit("{php echo $item['province']}","{php echo $item['city']}","{php echo $item['area']}");
    });
    {/if}

    function formcheck() {

        if ($("#title").isEmpty()) {
            Tip.focus("title", "请填写退货地址名称!", "top");
            return false;
        }

        if ($("#name").isEmpty()) {
            Tip.focus("name", "请填写联系人!", "top");
            return false;
        }

        if ($("#mobile").isEmpty()) {
            Tip.focus("mobile", "请填写手机!", "top");
            return false;
        }

        if($('#sel-province').val()=='请选择省份') {
            Tip.focus("sel-province", "请选择省份!", "top");
            return false;
        }

        if ($("#address").isEmpty()) {
            Tip.focus("address", "请填写地址!", "top");
            return false;
        }

        return true;
    }
</script>

{template '_footer'}